package com.xinxin.leetcode.problem492;

import java.util.Arrays;

/**
 * @author ShiXinXin
 * @date 2020-01-06 11:17
 */
public class Solution {
    public int[] constructRectangle(int area) {
        int w = (int) Math.sqrt(area);
        if (area % w == 0) {
            return new int[]{area / w, w};
        }
        while (--w > 0) {
            if (area % w == 0) {
                return new int[]{area / w, w};
            }
        }
        return new int[]{area, 1};
    }

    public static void main(String[] args) {
        System.out.println(Arrays.toString(new Solution().constructRectangle(4)));
    }
}
